package com.hardydou.framework.auth;

import org.springframework.stereotype.Component;
import org.thymeleaf.dialect.AbstractProcessorDialect;
import org.thymeleaf.processor.IProcessor;
import org.thymeleaf.standard.StandardDialect;
import org.thymeleaf.standard.processor.StandardXmlNsTagProcessor;
import org.thymeleaf.templatemode.TemplateMode;

import java.util.HashSet;
import java.util.Set;

/**
 * @author ：hardy
 * @description：thymeleaf 资源依赖标签
 * @date ：Created in 2020/5/30
 * @Copyright ：Hardydou.com
 */
@Component
public class AuthDialect extends AbstractProcessorDialect {

    private final static String NAME = "Data interface permission Dialect";
    private final static String PRE_FIX = "auth";

    protected AuthDialect() {
        super(NAME, PRE_FIX, StandardDialect.PROCESSOR_PRECEDENCE);
    }

    @Override
    public Set<IProcessor> getProcessors(String dialectPrefix) {
        final Set<IProcessor> processors = new HashSet<IProcessor>();
        processors.add(new AuthDataDepElementTagProcessor(dialectPrefix));
        processors.add(new StandardXmlNsTagProcessor(TemplateMode.HTML, dialectPrefix));
        return processors;
    }
}
